package com.ecs.simulator;

import java.util.Timer;
import java.util.TimerTask;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


import com.ecs.simulator.layout.ControlPanel;
import com.ecs.simulator.rooms.BathRoom;
import com.ecs.simulator.rooms.BedRoom;
import com.ecs.simulator.rooms.DiningRoom;
import com.ecs.simulator.rooms.LivingRoom;
import com.ecs.simulator.rooms.StudyRoom;

public class House {
	private BedRoom bedRoom;
	private BathRoom bathRoom;
	private DiningRoom diningRoom;
	private LivingRoom livingRoom;
	private StudyRoom studyRoom;
	
	static ControlPanel panel;
	
	public static SessionFactory factory;
	static{
		try {
			Configuration cfg = new Configuration().configure();
			factory = cfg.buildSessionFactory();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		new House();
	}
	
	public House(){
		try {
			panel = new ControlPanel();
			
			bedRoom = new BedRoom(panel);
			bathRoom = new BathRoom(panel);
		 	diningRoom = new DiningRoom(panel);
			livingRoom = new LivingRoom(panel);
			studyRoom = new StudyRoom(panel);
			
			Thread th1 = new Thread(bedRoom);
			Thread th2 = new Thread(bathRoom);
			Thread th3 = new Thread(diningRoom);
			Thread th4 = new Thread(livingRoom);
			Thread th5 = new Thread(studyRoom);
			
			th1.start();
			th2.start();
			th3.start();
			th4.start();
			th5.start();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
